home *** CD-ROM | disk | FTP | other *** search
/ Amiga Format CD 49 / Amiga Format CD49 (2000-01-17)(Future Publishing)(GB)(Track 1 of 3)[!][issue 2000-02].iso / +system+ / tools / virus / virus_checkerii / arexx / virus_checkerii.dopus5 < prev    next >
Text File  |  1999-11-01  |  7KB  |  205 lines

  1. /* Virus_Checker7 for Directory Opus 5 and Virus_Checker 7.
  2.    By Leo Davidson ("Nudel", Pot-Noodle/Gods'Gift Utilities)
  3.  
  4. $VER: Virus_Checker7 1.4 (31.10.98)
  5.  
  6.    Updated by Alex van Niel
  7.  
  8.    NOTE: This script _requires_ DOpus v5.11 or above and Virus_Checker II v1.0
  9.    or above.
  10.  
  11.    If you include the path of a file/dir on the command line, using a {}, only
  12.    this file/dir will be tested. If you omit the {}, the program will check
  13.    all selected files and directories in the SOURCE lister for viruses.
  14.  
  15.    If Virus_Checker's ARexx port is not found, the program will be run for
  16.    you (you should edit the path below). This means the script may fail if
  17.    you give an incorrect path to the Virus_CheckerII program.
  18.  
  19.    If the Virus_Checker's ARexx port takes over a minute to appear, an error
  20.    requester will appear on the DOpus screen and the script will quit.
  21.  
  22.    If Virus_CheckerII was running to start with, it will be left running after
  23.    the script has completed. Otherwise, it will be removed from memory.
  24.  
  25.    When a virus is detected a beep will sound and once all files have been
  26.    checked you will get a requester with a list of infected files (including
  27.    the type of virus). It is possible that the requester will fail to
  28.    appear if it becomes too large to fit on the screen. The script will
  29.    detect when this happens and output the results to a shell window instead.
  30.  
  31.    Thanks to John Veldthuis <johnv@tower.actrix.gen.nz> for writting
  32.    Virus_CheckerII, allowing me access to the VC7 beta versions, and for giving
  33.    me a virus-infected file (!) to test this script with.
  34.  
  35. For a "check selected files for viruses" function, call as:
  36. ------------------------------------------------------------------------------
  37. ARexx        DOpus5:ARexx/Virus_Checker7.dopus5 {Qp} {Ql}
  38. ------------------------------------------------------------------------------
  39. Turn off all switches.
  40.  
  41.  
  42. For an "Un-LhA to a directory and check for viruses" function, call as:
  43. ------------------------------------------------------------------------------
  44. AmigaDOS    C:LHA -M x {fu} {d}{ou-}/
  45. ARexx        DOpus5:ARexx/Virus_Checker7.dopus5 {Qp} {Ql} {d}{o-}
  46. ------------------------------------------------------------------------------
  47. Switches: Do all files
  48.           Output to window
  49.           Rescan dest
  50.           Window close button
  51.  
  52.     v1.00 -> v1.01    -    Some minor tidying up.
  53.                         Now checks to make sure the DOPUS.x port exists.
  54.     v1.02 -> v1.3    -    Now uses Show() instead of ShowList(). (Thanks Stoebi)
  55.                         Style Guide compliant version numbering and $VER string.
  56.  
  57.     v1.4            -    VCHECK.x.3 support
  58.  
  59. */
  60. /*- Path to Virus_CheckerII command ------------------------------------------*/
  61. Virus_CheckerII = "DH0:Tools/Harddrive/VirusKillers/Virus_CheckerII"
  62. /*--------------------------------------------------------------------------*/
  63. options results
  64. options failat 99
  65. signal on syntax;signal on ioerr        /* Error trapping */
  66. parse arg DOpusPort source_handle.0 FilePath
  67. DOpusPort = Strip(DOpusPort,"B",'" ')
  68. source_handle.0 = Strip(source_handle.0,"B",'" ')
  69. FilePath = Strip(FilePath,"B",'" ')
  70.  
  71. If DOpusPort="" THEN Do
  72.     Say "Not correctly called from Directory Opus 5!"
  73.     Say "Load this ARexx script into an editor for more info."
  74.     EXIT
  75.     END
  76. If ~Show("P",DOpusPort) Then Do
  77.     Say DOpusPort "is not a valid port."
  78.     EXIT
  79.     End
  80. Address value DOpusPort
  81.  
  82. Quit_After = "NO"
  83. If ~Show("P","Virus_CheckerII") Then Do
  84.     Address Command Virus_CheckerII
  85.     Quit_After = "YES"
  86.     TickTick = Time(M)
  87.     Do While ~Show("P","Virus_CheckerII")
  88.         IF Time(M) - TickTick > 1 Then Do
  89.             dopus request '"Error loading Virus_CheckerII!'|| '0a'x ||'Check its command-line in the ARexx script itself." OK'
  90.             EXIT
  91.             END
  92.         END
  93.     END
  94.  
  95. /* If file/dir-path was specified on command line, check it, else
  96.    go through all the selected ones. */
  97.  
  98. BadList = ""
  99. BadNumber = 0
  100.  
  101. /*
  102. lister query source stem source_handle.
  103. IF source_handle.count = 0 | source_handle.count = "SOURCE_HANDLE.COUNT" Then Do
  104.     dopus request '"You must have a SOURCE lister!" OK'
  105.     EXIT
  106.     End
  107. */
  108.  
  109. If FilePath = "" Then Do
  110.     lister set source_handle.0 busy 1
  111.  
  112.     lister query source_handle.0 numselentries    /* Get info about selected */
  113.     Lister_NumSelEnt = RESULT            /* entries & path to them */
  114.     lister query source_handle.0 path
  115.     Lister_Path = Strip(RESULT,"B",'"')
  116.  
  117.     lister set source_handle.0 progress Lister_NumSelEnt "Checking for viruses..."
  118.  
  119.     Do i=1 to Lister_NumSelEnt
  120.         lister query source_handle.0 abort
  121.         If RESULT=1 Then BREAK
  122.         lister query source_handle.0 firstsel
  123.         Temp_Name = Strip(RESULT,"B",'"')
  124.         lister select source_handle.0 Temp_Name 0
  125.         Temp_Path = Lister_Path || Temp_Name
  126.         lister set source_handle.0 progress name Temp_Name
  127.         lister set source_handle.0 progress count i
  128.         Address "Virus_CheckerII" "Scan "||Temp_Path
  129.         If VCHECK.0.0 ~= 0 Then Do
  130.             command beep
  131.             Do x=1 to VCHECK.0.0
  132.                 BadNumber = BadNumber + 1
  133.  
  134.                 If VCHECK.x.3 = "" Then Do
  135.                     BadList = BadList || '0a'x || VCHECK.x.1 || " (" || VCHECK.x.2 || ")"
  136.                     END
  137.                 Else Do
  138.                     BadList = BadList || '0a'x || VCHECK.x.1 ||" -> " || VCHECK.x.3 || " (" || VCHECK.x.2 || ")"
  139.                     END
  140.                 END
  141.             END
  142.         END
  143.     lister clear source_handle.0 progress
  144.     End
  145.  
  146. ELSE Do
  147.     lister set source_handle.0 progress "-1" "Checking for viruses..."
  148.     Address "Virus_CheckerII" "Scan "||FilePath
  149.     If VCHECK.0.0 ~= 0 Then Do
  150.         command beep
  151.         Do x=1 to VCHECK.0.0
  152.             BadNumber = BadNumber + 1
  153.             If VCHECK.x.3 = "" Then Do
  154.                 BadList = BadList || '0a'x || VCHECK.x.1 || " (" || VCHECK.x.2 || ")"
  155.                 END
  156.             Else Do
  157.                 BadList = BadList || '0a'x || VCHECK.x.1 ||" -> " || VCHECK.x.3 || " (" || VCHECK.x.2 || ")"
  158.             END
  159.         END
  160.     END
  161.     lister clear source_handle.0 progress
  162. End
  163.  
  164. If BadNumber > 0 Then Do
  165.     If BadNumber = 1 Then
  166.         BadNote = "The following file is infected:"
  167.     Else
  168.         BadNote = "The following files are infected:"
  169.     BadList = "*VIRUS WARNING*" || '0a'x || BadNote || '0a'x || "(Virus name in parenthesis)" || '0a'x || BadList
  170.  
  171.     dopus request '"'||BadList||'" OK'
  172.  
  173. /* As there is only one gadget which returns "RC = 1", when "RC = 0" it means
  174.    that the requester failed to appear. This will happen when the list is too
  175.    long or wide to fit on the screen, which could easily happen with a virus
  176.    which has spread itself to many files!
  177.  
  178.    So, if the requester failed, the output will be sent to a shell window.
  179.    It would be nice to be able to use the user's defined output-window
  180.    size but there is (currently) no way of obtaining this. */
  181.  
  182.     IF RC = 0 Then Do
  183.         dopus request '"*VIRUS WARNING*' || '0a'x || 'List too large for requester' || '0a'x || 'and will be output to a shell..." OK'
  184.         Open(Output_Shell,"CON:0/1/640/200/Virus Warning/CLOSE/WAIT","W")
  185.         WriteLN(Output_Shell,BadList)
  186.         Close(Output_Shell)
  187.         END
  188.     END
  189.  
  190. /*-- Restore the Lister for normal use --------------------------------------*/
  191. syntax:;ioerr:                /* In case of error, jump here */
  192. END_PART_2:
  193.  
  194. lister clear source_handle.0 progress
  195.  
  196. If FilePath = "" Then Do
  197.     lister refresh source_handle.0
  198.     lister set source_handle.0 busy 0
  199.     END
  200.  
  201. END_PART:
  202. If Quit_After = "YES" Then Address "Virus_CheckerII" QUIT
  203.  
  204. EXIT
  205.